package com.unsiv.torch;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.ImageView;

/**
 * <p>
 * start activity
 * </p>
 * @author fanzhen
 * @time 7:31:13 PM Aug 26, 2011
 * @email fanzhen.meng@gmail.com
 */
public class Navigate extends Activity {
	private ImageView image;
	private int step = 1;
	private String type;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		this.setContentView(R.layout.navigate);
		image = (ImageView)findViewById(R.id.image);
		Intent intent = getIntent();
		type = intent.getStringExtra("type");
		changeStep(step);
		image.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				step++;
				changeStep(step);
			}
		});
	}
	private void changeStep(int step) {
		if(1==step){
			image.setVisibility(View.VISIBLE);
			if ("screen".equals(type)) {
				image.setBackgroundResource(R.drawable.nv_screen);
			} else {
				image.setBackgroundResource(R.drawable.nv_led);
			}
		}else if(2==step){
			image.setBackgroundResource(R.drawable.nv_02);
		}else if(3==step){
			image.setBackgroundResource(R.drawable.nv_03);
		}else if(4==step){
			image.setBackgroundResource(R.drawable.nv_04);
		}else if(5==step){
			image.setBackgroundResource(R.drawable.nv_05);
		}else if(6==step){
			Intent intent = new Intent(getApplicationContext(),NavigateFinish.class);
			intent.putExtra("type", type);
			startActivity(intent);
		}
	}
	public boolean onCreateOptionsMenu(Menu menu) {
		menu.add(0, 0, 0, "Exit");
		return true;
	}
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case 0:
			MyCamaraHelper.turnOff();
			new ActivityUtil(this).exit();
			return true;
		}
		return false;
	}
}